/************************************************************************/
// Copyright (C) 2016, han_gangbiao. All rights reserved.
// Use of this source code is governed by a GPL-v2 license that can be found in the License file.
// 
// [Time]:      2016-1-4 21:53:17
// [Author]:    han_gangbiao [http://my.oschina.net/jackhen]
// [Info]:      
/************************************************************************/

#ifndef INCLUDE_NET_NETINSIDE_OS_NS_SYS_SOCKET_H_
#define INCLUDE_NET_NETINSIDE_OS_NS_SYS_SOCKET_H_

#include "net/netbasedefine.h"

namespace netos {
	inline SOCK_FD socket( int addr_family, int type, int protocol );

    inline SOCK_FD accept( SOCK_FD fd, struct sockaddr* addr, int* addrlen );
    inline int listen( SOCK_FD fd, int backlog );
    inline int bind( SOCK_FD fd, const struct sockaddr* addr, int addrlen );

    inline int connect( SOCK_FD fd, const struct sockaddr* addr, int addrlen );

    inline int getpeername( SOCK_FD fd, struct sockaddr* addr, int* addrlen );
    inline int getsockname( SOCK_FD fd, struct sockaddr* addr, int* addrlen );

    inline int recv( SOCK_FD fd, char* buf, int len, int flags = 0 );
    inline int send( SOCK_FD fd, const char* buf, int len, int flags = 0 );

    inline int recvfrom( SOCK_FD fd, char* buf, int len, int flags, struct sockaddr* from, int* fromlen );
    inline int sendto( SOCK_FD fd, const char* buf, int len, int flags, const struct sockaddr* to, int tolen );

    inline int setsockopt( SOCK_FD fd, int level, int optname, const char* optval, int optlen );
    inline int getsockopt( SOCK_FD fd, int level, int optname, char* optval, int* optlen );

    inline int closesocket( SOCK_FD fd );
    inline int shutdown( SOCK_FD fd, int how );

    inline int ioctl_nonblock( SOCK_FD fd );

} //~netos namespace

#include "os_ns_sys_socket.inl"

#endif //~INCLUDE_NET_NETINSIDE_OS_NS_SYS_SOCKET_H_
